package com.zzw.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.zzw.bean.Agent;
import com.zzw.bean.Msg;
import com.zzw.bean.SysUser;
import com.zzw.service.AgentService;
import com.zzw.service.RedisCacheService;
import com.zzw.service.SysUserService;
import com.zzw.utils.OssUtil;
import com.zzw.utils.ShiroUtils;
import com.zzw.utils.WebUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.DisabledAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.management.resources.agent;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * 代理商管理接口
 * @author 赵志伟
 * @version 1.0
 */
@SuppressWarnings({"all"})
@Controller
@RequestMapping("/agent")
public class AgentController {

    @Resource
    private AgentService agentService;

    @GetMapping("/selectAgentList")
    @ResponseBody
    public Msg selectAgentList() {
        List<Agent> agentList = agentService.selectAgentList();
        return Msg.success().add("agentList", agentList);
    }

    @PostMapping("/insertAgent")
    @ResponseBody
    public Msg insertAgent(@RequestBody Agent agent) {
        agentService.insertAgent(agent);
        return Msg.success();
    }

    @PutMapping("/updateAgentStatus/{id}")
    @ResponseBody
    public Msg updateAgentStatus(@PathVariable("id")  Integer id) {
        agentService.updateAgentStatus(id);
        return Msg.success();
    }
}
